@layout("/common/_container.html"){
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="classInfoForm">
            <input type="hidden" id="orgId" value="${org.id}">
            <input type="hidden" id="phase_gradeMap" value='${phase_gradeMap}'>
            <div class="row">
                <div class="col-sm-12 b-r" id="class-add">
                    <#input id="orgName" name="学校名称" value="${org.name}" underline="true" disabled="disabled"/>
                    <#input id="name" name="班级名称" underline="true" span="true"/>
                    <#select id="period" name="级届" underline="true" span="true">
                    @for(period in periodList){
                    <option value="${period}">${period}届</option>
                    @}
                </#select>
                <#select id="phaseId" name="学段" underline="true" onchange="guanlian();" span="true">
                <option value="">请选择</option>
                @for(phaseMeta in phaseList){
                <option value="${phaseMeta.id}">${phaseMeta.name}</option>
                @}
            </#select>
            <#select id="gradeId" name="年级" underline="true" onchange="suggestTeacherList1();" span="true">
            <option value="">请选择</option>
        </#select>
        <#select id="classType" name="班级类型" underline="true">
        @for(classTypeMeta in classTypeList){
        <option value="${classTypeMeta.id}">${classTypeMeta.name}</option>
        @}
    </#select>
    <#select id="teacherId" name="班主任" underline="true" >
    <option value="">请选择</option>
</#select>
    <#input id="sort" name="排序" underline="true" span="true"/>

</div>
</div>
</div>

<div class="row btn-group-m-t">
    <div class="col-sm-10" style="text-align: center">
        <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="PtClassInfoDlg.addSubmit()"/>
        <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="PtClassInfoDlg.close()"/>
    </div>
</div>
</div>

</div>
</div>
<script src="${ctxPath}/static/modular/system/ptClass/ptClass_info.js"></script>
<script>
    function guanlian() {
        showGradeList1();
        //showTeacherList(obj);
    }

    //显示年级
    function showGradeList1() {
        var gradeOptions = "<option value=''>请选择...</option>";
        $("#gradeId").html(gradeOptions);
        var teacherNameStr = "<option value=''>请选择...</option>";
        $("#teacherId").html(teacherNameStr);
        var phaseId = $("#phaseId").val();

        var map = JSON.parse(($("#phase_gradeMap").val()));
        var gradeList = map[phaseId];
        if (gradeList != null) {
            $.each(gradeList, function (n, grade) {
                gradeOptions += "<option value='" + grade.id + "' ";
                gradeOptions += ">" + grade.name + "</option>";
            });
        }
        $("#gradeId").html(gradeOptions);
    }

    function suggestTeacherList1() {
        var teacherNameStr = "<option value=''>请选择...</option>";
        $("#teacherId").html(teacherNameStr);
        var phaseId = $("#phaseId").val();
        var gradeId = $("#gradeId").val();
        var orgId = $("#orgId").val();
        if (phaseId==null){
            layer.error("请选择学段");
            return;
        }
        if (gradeId==null){
            layer.error("请选择年假");
            return;
        }
        $.ajax({
            type: 'POST',
            url: Feng.ctxPath + "/ptClass/suggestTeacherList1",
            data: {'phaseId': phaseId, 'orgId': orgId, 'gradeId': gradeId},
            dataType: "json",
            success: function (data) {
                var teacherList = data;
                if (teacherList.length>0) {
                    for (var i = 0; i < teacherList.length; i++) {
                        teacherNameStr +='<option value="' + teacherList[i].accountId + '">'+teacherList[i].name+'</option>';
                    }

                }
                $("#teacherId").html(teacherNameStr);
            },
        });
    }
</script>
@}
